<template>
  <div class="printOrder">
    <div v-if="printConfig.type !== 1"><span class="fw-7">订单编号：</span>{{ info.orderNo }}</div>
    <div class="tc fz-16 fw-7 py-6">
      {{ printConfig.title || info.checkAgencyName }}
    </div>
    <div v-if="printConfig.type === 1" class="tc fz-14 fw-7">
      <span>处方笺</span>
      <span v-if="prescriptionInfo">{{ getMaterialsType(prescriptionInfo) }}</span>
    </div>
    <ParescriptNum :info="info" :serviceDetailIndex="serviceDetailIndex" style="border-bottom: solid 1px #cfcfcf" />

    <div class="py-6">
      <div class="disFlxJS py-3">
        <div class="shrink0">
          <span class="fw-7">姓名：</span>
          <span>{{
            info.parescriptOrder
              ? info.parescriptOrder.patientName
              : info.username
          }}</span>
        </div>
        <div class="px-6 shrink0">
          <span class="fw-7">性别：</span>
          <span v-if="info.parescriptOrder">{{
            info.parescriptOrder.patientSex === 1 ? "女" : "男"
          }}</span>
        </div>
        <div class="px-6 shrink0">
          <span class="fw-7">年龄：</span>
          <span v-if="info.parescriptOrder"
            >{{ info.parescriptOrder.patientAge }} 岁</span
          >
        </div>
        <div class="shrink0">
          <span class="fw-7">电话：</span>
          <span>{{
            info.parescriptOrder
              ? info.parescriptOrder.patientPhone
              : info.userphone
          }}</span>
        </div>
      </div>
      <div class="disFlx py-3">
        <div class="fw-7 shrink0">
          {{ printConfig.type !== 1 ? "收货信息" : "家庭住址" }}：
        </div>
        <div>{{ getShippingAddress(info) }}</div>
      </div>

      <ParescriptType :info="info" :prescriptionInfo="prescriptionInfo" styleType="print">
        <div class="disFlx py-3">
          <span class="fw-7 shrink0">诊断证型：</span>
          <span>{{
            info.parescriptOrder
              ? info.parescriptOrder.typesResult
              : info.initialDiagn
          }}</span>
        </div>
      </ParescriptType>
    </div>

    <ParescriptItem  :info="info" :prescriptionInfo="prescriptionInfo" :printConfig="printConfig" styleType="print">
      <div v-if="printConfig.type !== 1" class="shrink0 disFlxAC flexEnd pt-6">
        <span class="pr-5">开方医生：</span>
        <img
          v-if="info.parescriptOrder && info.parescriptOrder.signImg"
          :src="info.parescriptOrder.signImg"
          style="width: 80px; height: auto"
        />
        <img
          v-else-if="info.parescriptOrder && info.parescriptOrder.prescriptionSign"
          :src="info.parescriptOrder.prescriptionSign"
          style="width: 80px; height: auto"
        />
        <span v-else style="min-width: 80px">{{ info.sponsor }}</span>
      </div>
      <div v-else style="flex: 1; text-align: center; padding: 10px 0 20px 0">
        -------------- 以下空白 --------------
      </div>
      <div v-if="printConfig.type === 1" class="bomTips">
        <div class="pr-25">大额处方意见：</div>
        <div>同意</div>
        <div class="checkedBox"></div>
        <div class="pl-10">签名：</div>
        <div style="width: 100px"></div>
      </div>
      <div
        :style="
          printConfig.type !== 1 ? 'margin-bottom: 5%;' : 'margin-bottom: 8%;'
        "
      ></div>
    </ParescriptItem>

    <div v-if="printConfig.type !== 1" class="py-10 disFlx">
      <div class="fw-7 shrink0">温馨提示：</div>
      <div>
        <span
          v-for="(tip, tipIndex) in [
            '请遵医嘱用药',
            '请将药品放阴凉干燥处保存',
          ]"
          :key="tipIndex"
          :class="{ 'pl-15': tipIndex !== 0 }"
          >{{ tipIndex + 1 + "、" + tip }}</span
        >
      </div>
    </div>
    <div v-else>
      <div class="disFlxJS">
        <div class="shrink0 disFlxAC" style="height: 40px">
          <span class="fw-7 fz-14">医生：</span>
          <img
            v-if="info.parescriptOrder && info.parescriptOrder.signImg"
            :src="info.parescriptOrder.signImg"
            style="height: 30px; width: 50px"
          />
          <img
            v-if="info.parescriptOrder && info.parescriptOrder.prescriptionSign"
            :src="info.parescriptOrder.prescriptionSign"
            style="height: 30px; width: 50px"
          />
          <div v-else style="width: 50px"></div>
        </div>
        <div class="shrink0 pr-50">
          <span class="fw-7 fz-14">审核：</span>
        </div>
        <div class="shrink0 pr-50">
          <span class="fw-7 fz-14">煎煮：</span>
        </div>
        <div class="shrink0 pr-50">
          <span class="fw-7 fz-14">调配：</span>
        </div>
        <div class="shrink0 pr-50">
          <span class="fw-7 fz-14">核发：</span>
        </div>
      </div>
      <div>
        除主诊医师特别注明外，处方仅当日有效。按卫生部规定，药房药品一经发出，不得退换。
      </div>
      <div class="pt-5">打印时间：{{ parseTime(new Date()) }}</div>
    </div>
  </div>
</template>

<script>
import { getShippingAddress } from './mixin.js'
import ParescriptNum from './prescription/num.vue'
import ParescriptType from './prescription/type.vue'
import ParescriptItem from './prescription/item.vue'

export default {
  components: {
    ParescriptNum,
    ParescriptType,
    ParescriptItem
  },
  props: {
    info: {
      type: Object,
      default: () => { }
    },
    printConfig: {
      type: Object,
      default: () => { }
    },
    prescriptionInfo: {
      type: Object,
      default: () => { }
    },
    serviceDetailIndex: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {}
  },
  methods: {
    getShippingAddress,

    getMaterialsType(item) {
      const { serviceItems, dictLabel } = item;
      if(serviceItems == 4 && (dictLabel === '中药饮片' || dictLabel === '中药颗粒' || dictLabel === '西药')){
        return `（${dictLabel}）`
      }else{
        return ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.colorY {
  color: #bb9313;
}
</style>
